<template>
    <div>
        <el-button @click="getName">请求数据</el-button>
        
        <ul>
            <li v-for="(item, index) in result" :key="index">
                {{item.name}}
            </li>
        </ul>

        <el-button @click="getLocal">请求本地</el-button>
        <ul>
            <li v-for="(item,index) in localResult" :key="index">{{item.name}}</li>
        </ul>

        <hr>

    </div>
</template>
<script>
import axios from 'axios'
export default {
    data() {
        return {
            result:[],
            localResult:[]
        }
    },
    methods:{
        getName() {
            axios.get('http://localhost:8080/api/get_user_list').then(res => {
                console.log("请求数据1：",res);
                this.result = res.data.data
            }).catch(err =>{
                console.log("请求失败：",err)
            })
        },

        getLocal(){
             axios.get('http://localhost:8080/aa.json').then(res => {
                console.log("请求数据：",res);
                this.localResult = res.data
            }).catch(err =>{
                console.log("请求失败：",err)
            })
        }
        
    }
}
</script>